package com.qqls.youxiangousys.pj.sys.controller;

import com.qqls.youxiangousys.pj.common.entity.JsonResult;
import com.qqls.youxiangousys.pj.common.entity.Pagination;
import com.qqls.youxiangousys.pj.sys.entity.SysCategory;
import com.qqls.youxiangousys.pj.sys.entity.SysOrder;
import com.qqls.youxiangousys.pj.sys.service.SysOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单明细
 */
@RequestMapping("order")
@RestController
public class SysOrderController {
    @Autowired
    private SysOrderService orderService;
    /**
     * 根据订单号查订单
     * @param orderNumber
     * @param curPage
     * @param pageSize
     * @param state
     * @return
     */
    @RequestMapping("findOrder")
    public JsonResult findOrder(String orderNumber,Integer curPage,Integer pageSize,Integer state,String startTime, String endTime){
        System.out.println(state);
        Pagination pagination = orderService.findOrder(orderNumber,curPage,pageSize,state,startTime, endTime);
        return new JsonResult(pagination);
    }

    @RequestMapping("updateState")
    public  JsonResult updateState(Integer id,  Integer state){
        System.out.println(state);
            JsonResult jr = new JsonResult(orderService.updateState(id,state));
            jr.setMessage("修改成功");
            return jr;
    }

    /**
     * 通过id删除角色
     * @param id
     * @return
     */
    @RequestMapping("deleteOrder")
    public JsonResult deleteOrder(Integer id) {
        JsonResult jr = new JsonResult(orderService.deleteOrder(id));
        jr.setMessage("删除成功");
        return jr;
    }
}
